﻿using System;
using System.Data;
using System.Configuration;

using System.Web;

using DatabaseService;

/// <summary>
/// Summary description for GoldenPrice_Factory
/// </summary>
/// 
namespace WorldGoldenPrice
{
    public class GoldenPrice_Factory
    {
        public string World_Buy;
        public string World_Sell;
        public string Vn_Buy;
        public string Vn_Sell;
        public string OilBuy;
        public string OilSell;
        public string EURUSD;
        public string GBPUSD;
        public string USDJPY;
        public string USDCAD;
        public string AUDUSD;
        public string NZDUSD;
        public string USDNOK;

        public GoldenPrice_Factory()
        {

        }

        public void getPrice(string className)
        {
            Object obj = Activator.CreateInstance(Type.GetType("WorldGoldenPrice."+className));
            GoldenPrice GP = obj as GoldenPrice;
            GP.getPrice();
            this.World_Buy = GoldenPrice.UniqueInstance.WorldBuy;
            this.World_Sell = GoldenPrice.UniqueInstance.WorldSell;
            this.Vn_Buy =  GoldenPrice.UniqueInstance.VnBuy;
            this.Vn_Sell = GoldenPrice.UniqueInstance.VnSell;
            this.OilBuy =  GoldenPrice.UniqueInstance.OilBuy ;
            this.OilSell = GoldenPrice.UniqueInstance.OilSell;
            this.EURUSD =  GoldenPrice.UniqueInstance.EURUSD;
            this.GBPUSD =  GoldenPrice.UniqueInstance.GBPUSD;
            this.USDJPY =  GoldenPrice.UniqueInstance.USDJPY;
            this.USDCAD =  GoldenPrice.UniqueInstance.USDCAD;
            this.AUDUSD =  GoldenPrice.UniqueInstance.AUDUSD;
            this.NZDUSD =  GoldenPrice.UniqueInstance.NZDUSD;
            this.USDNOK =  GoldenPrice.UniqueInstance.USDNOK;

        }

        public bool writeToDB(string className)
        {
            this.getPrice(className);
            AccessDB.InsertGoldenPriceDB(this, className);
            return true;
        }
    }
}